<?php
/**
 *	css.php - CSS Server, Output class parses CSS, This file returns it..DONE!
 *	This is Smit Matterhorn - Build 24109
 *	
 *
 * @author		The SmitBoard Team & Community
 * @license		GNU GPL v3
 * @link		http://smitboard.sf.net
 * @since		Matterhorn
 */
 
if(!defined('MAIN_PATH'))
{
	define('MAIN_PATH', '../');
}

// Run the Initialiser
require_once MAIN_PATH . 'init.' . pathinfo(__FILE__, PATHINFO_EXTENSION);

// Now Communicate with the output class..
$Smit->output->sendContent('css');

// Oi! Oi! Your not supposed to exploit this!?
$stdin = str_replace(array('/', '.'), '', $Smit->lib->input_get('in'));
$location = str_replace(array('/', '.'), '', $Smit->lib->input_get('loc'));
// O, Wait..You can't..Guess who is laughing (Replaces '.', '/' this means scheme:// is stripped too)

$location = ($location == 'style' ? $Smit->output->cwd . 'styles/' : SMIT_ASSETS_PATH) . $stdin . '.css';

// No File to parse? Let's just send blank output.
if(!file_exists($location))
{
	exit;
}

// Let's fetch the file contents
$rawcss = file_get_contents($location);

$ltr = $Smit->lang('config.ltr');
$lang_left = ($ltr == 1 ? 'left' : 'right');
$lang_right = ($ltr == 1 ? 'right' : 'left');

$tags = array(
	'{smit.mediaurl}' => $Smit->output->url . 'media/',
	'smit.left' => $lang_left,
	'smit.right' => $lang_right,
	'smit.margin-left' => 'margin-' . $lang_left,
	'smit.margin-right' => 'margin-' . $lang_right,
	'smit.padding-left' => 'padding-' . $lang_left,
	'smit.padding-right' => 'padding-' . $lang_right,
	'smit.border-left' => 'border-' . $lang_left,
	'smit.border-right' => 'border-' . $lang_right,
	//'"Lucida Grande",' => '"Trebuchet MS",',
);
echo str_replace(array_keys($tags), array_values($tags), $rawcss);
?>